home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / util / arc / Repack2.lha / Repack.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1995-02-10  |  3.2 KB  |  92 lines

  1. /* LHA-LZX V1.0 by Mat Bettinson of the Plot Hatching Factory '95
  2.  
  3. Since Jonathan Forbes' brilliant LZX came along and promptly blew LHA away,
  4. there's a need for a bulk converter. This is such a device.
  5.  
  6. Simply executing the script with the Directory to convert will result
  7. in each and every single LHA or LZH file in that dir being converted to LZX.
  8.  
  9. You'll need LHA and LZX in your path and the Delete command.
  10. It also needs a fat temp dir as large as the largest uncompressed archive
  11. to work and this is the first thing in the script so you can alter at will.
  12.  
  13. Below is the two only real values you must change. One is the Temp Dir where
  14. all LHA files will be extracted to. There must be enough room in this drawer
  15. for the largest of archives to unpack to so I DO NOT recommend RAM: unless you
  16. have a great DEAL of RAM. Beware! LZX eats memory too. The other parameter is
  17. the compression mode. It can be 1,2 or 3 varying from fastest & Lowest CR to 
  18. Slowest & Highest CR. Even mode 1 is better than LHA.
  19.  
  20. New for 2.0:
  21.  
  22. Priority setting in header below.
  23.  
  24. By default, will not replace LHA archives if larger using LZX.
  25.  
  26. Above can be disabled so that ALL files are replaced as per original Repack by
  27. using the 'FORCELZX' switch after the Dir name.
  28.  
  29. Filenotes are copied.
  30. */
  31.  
  32. TempDir  = 'Spot:temp/'
  33. Mode     = '2'
  34. Priority = -1
  35.  
  36. /*************************************************/
  37. /* I recommend you leave it alone from here. :-) */
  38. /*************************************************/
  39.  
  40. Arg Dir Force
  41. say 
  42. say ' *** LHA-LZX repacker 2.0 by Mat Bettinson of the Plot Hatching Factory ***'
  43. If Dir = '' then signal Usage
  44. If ~EXISTS(Dir) then signal Usage
  45. If Force ~= '' & Force ~= 'FORCELZX' then signal Usage
  46. If Force = 'FORCELZX' then ForceLZX = 1
  47. ELSE ForceLZX = 0
  48. say
  49. Call Pragma('S',50000)
  50. If right(Dir,1) ~= '/' & right(Dir,1) ~= ':' then Dir = Dir'/'
  51. Address COMMAND 'Assign REPACK: 'Tempdir
  52. Call Pragma('D','REPACK:')
  53. Address COMMAND 'List 'Dir' PAT #?(.LZH|.LHA) FILES LFORMAT "%n %c" >t:LHA-LZX.temp'
  54. Call Open(list,'t:LHA-LZX.temp','R')
  55. BSave = 0
  56. DO forever
  57.  Line = ReadLN(list)
  58.  File = strip(word(line,1)) ; Comment = strip(word(line,2)) ; Comment = Strip(Comment,'B','"')
  59.  IF EOF(list) then break
  60.  NewFile = Left(File,Length(file)-3)'LZX'
  61.  say 'Converting file: 'File
  62.  Address COMMAND 'Delete >NIL: REPACK:#? ALL FORCE'
  63.  Call Open(ts,Dir||file) ; Lhasize = Seek(ts,0,'E') ; Call Close(ts)
  64.  Address COMMAND 'LHA -a -F -M -P'Priority' x 'Dir||File' #? REPACK:'
  65.  Address COMMAND 'LZX -r -e -M500 -'Mode' -P'Priority' -F a 'Dir||NewFile' REPACK:#?'
  66.  Call Open(ts,Dir||NewFile) ; Lzxsize = Seek(ts,0,'E') ; Call Close(ts)
  67.  Diff = Lhasize - Lzxsize
  68.  If Diff > 0 | ForceLZX then DO
  69.   Address COMMAND 'Delete >NIL: 'Dir||File
  70.   If Comment ~= '' then Address COMMAND 'Filenote 'DIR||NewFile' "'Comment'"'
  71.   say '* 'Diff' bytes saved on this archive!' ; say
  72.   END
  73.  ELSE DO
  74.   Address COMMAND 'Delete >NIL: 'Dir||Newfile
  75.   say '* LZX file 'ABS(Diff)' bytes larger than LZX. Keeping LHA...' ; say
  76.   Diff = 0
  77.   END
  78.  BSave = BSave + Diff
  79.  END
  80. Call Close(list)
  81. Address COMMAND 'Assign REPACK: REMOVE'
  82. say
  83. say ' *** LHA-LZX Repacker 2.0 finished. 'Bsave' bytes saved in this dir. ***'
  84. say
  85. EXIT
  86.  
  87. Usage:
  88. say 
  89. say 'Usage: [rx] Repack <Directory> [FORCELZX]'
  90. say
  91. EXIT
  92.